#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from Bio import SeqIO
import os
import sys

if __name__ == '__main__':
    outfilepath = sys.argv[2]
    outfileparentpth = outfilepath[:outfilepath.rindex("/")]
    os.makedirs(outfileparentpth, exist_ok=True)

    path = os.path.abspath(sys.argv[1])
    for file in os.listdir(path):
        abspath = os.path.join(path, file)
        for seq_record in SeqIO.parse(abspath, "fasta"):
            SeqIO.write(seq_record, outfilepath, "fasta")
        print(abspath + " wrote.")